package com.house.service.impl;

import com.house.entity.Order;
import com.house.mapper.OrderMapper;
import com.house.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;
    @Override
    public void createAppointment(Order order) {
        order.setStatus("PENDING");
        orderMapper.insertOrder(order);
    }

    @Override
    public void confirmAppointment(Long orderId, Long landlordId, String status) {
        orderMapper.updateOrderStatus(orderId, landlordId, status);
    }

    @Override
    public void payOrder(Long orderId, Long tenantId) {
        orderMapper.payOrder(orderId, tenantId);
    }

    @Override
    public List<Order> getOrdersByTenant(Long tenantId) {
        return orderMapper.findOrdersByTenantId(tenantId);
    }

    @Override
    public List<Order> getOrdersByLandlord(Long landlordId) {
        return orderMapper.findOrdersByLandlordId(landlordId);
    }
}
